﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApprovalManagePage.aspx.cs" Inherits="KPI_SYSTEM.ApprovalPage.ApprovalManagePage" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <link rel="stylesheet" href="../res/third-party/jqueryuiautocomplete/jquery-ui.css" />
    <style>
       
    </style>
</head>
<body style="overflow: -Scroll; overflow-x: hidden">

    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" />
        <f:Form ID="Form2" IsFluid="true" CssClass="blockpanel" BodyPadding="5 5 0 5" LabelAlign="Left" ShowHeader="false"
            Title="查询" runat="server">
            <Rows>
                <f:FormRow ColumnWidths="15% 15% 15% 15% 15% 15%">
                    <Items>
                        <f:TextBox runat="server" ID="tbxNameSerach" Label="流程名称"></f:TextBox>
                        <f:Button ID="btnSearch" Text="搜索" Icon="Magnifier" runat="server" OnClick="btnSearch_Click"></f:Button>
                    </Items>
                    <Items>
                    </Items>
                </f:FormRow>
            </Rows>
        </f:Form>
        <f:Panel ID="Panel16" ShowHeader="false" CssClass="" ShowBorder="false" Layout="VBox" runat="server" AutoScroll="true">
            <Items>
                <f:Grid ID="Grid1" IsFluid="true" CssClass="blockpanel" ShowBorder="true" ShowHeader="true" Width="400px" EnableCollapse="false"
                    runat="server" DataKeyNames="REC_ID" AllowCellEditing="false" PageSize="15" AllowPaging="true" OnRowCommand="Grid1_RowCommand" OnPreRowDataBound="Grid1_PreRowDataBound"
                    DataIDField="REC_ID" Title="审批流程列表">
                    <Toolbars>
                        <f:Toolbar ID="Toolbar2" Position="Top" runat="server">
                            <Items>
                                <f:Button ID="btnNew" Text="新增" Icon="Add" EnablePostBack="false" runat="server">
                                    <Listeners>
                                        <f:Listener Event="click" Handler="onNewButtonClick" />
                                    </Listeners>
                                </f:Button>
                                <f:Button ID="btnEditApprovalProcess" Text="编辑流程" Icon="TextListBullets" EnablePostBack="true" EnableAjax="false"
                                    runat="server" OnClick="btnEditApprovalProcess_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                    <Columns>
                        <f:RenderField Width="150px" ColumnID="APPROVAL_NAME" DataField="APPROVAL_NAME"
                            HeaderText="流程名称">
                        </f:RenderField>
                        <f:RenderField Width="80px" ColumnID="APPROVAL_STATUS_NAME" DataField="APPROVAL_STATUS_NAME"
                            HeaderText="是否启用">
                        </f:RenderField>
                        <f:RenderField Width="200px" ColumnID="APPROVAL_REMARK" DataField="APPROVAL_REMARK"
                            HeaderText="流程备注">
                        </f:RenderField>
                        <f:RenderField Width="200px" ColumnID="APPROVAL_MAPPING_NAME" DataField="APPROVAL_MAPPING_NAME"
                            HeaderText="对应模块">
                        </f:RenderField>
                        <f:RenderField Width="200px" Hidden="true" ColumnID="APPROVAL_MAPPING" DataField="APPROVAL_MAPPING"
                            HeaderText="对应模块ID">
                        </f:RenderField>
                        <f:RenderField Width="200px" Hidden="true" ColumnID="APPROVAL_STATUS" DataField="APPROVAL_STATUS"
                            HeaderText="是否启用ID">
                        </f:RenderField>
                        <f:LinkButtonField ColumnID="Edit" Width="50px" EnablePostBack="true" Icon="Pencil" />
                        <f:LinkButtonField Width="50px" ConfirmText="删除选中行？" ConfirmTarget="Top"
                            CommandName="Delete" Icon="Delete" />
                    </Columns>
                </f:Grid>

            </Items>
        </f:Panel>
        <f:Window ID="Window1" Title="新增流程" Hidden="true" EnableIFrame="false" AutoScroll="true"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="950px">
            <Items>
                <f:SimpleForm ID="SimpleForm1" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:Panel ID="Panel1" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:HiddenField ID="hfFormID" runat="server"></f:HiddenField>
                                <f:TextBox ID="tbxFormAPPROVAL_NAME" runat="server" Width="310px" CssClass="marginr" Label="流程名称" ShowRedStar="true" Required="true">
                                </f:TextBox>
                                <f:TextBox ID="tbxFormAPPROVAL_REMARK" runat="server" Width="310px" MarginLeft="20px" CssClass="marginr" Label="流程备注">
                                </f:TextBox>
                                <f:DropDownList ID="ddlFormAPPROVAL_STATUS" Width="310px" MarginLeft="20px" Label="是否启用" AutoSelectFirstItem="true" runat="server">
                                    <f:ListItem Text="启用" Value="1" />
                                    <f:ListItem Text="停用" Value="0" />
                                </f:DropDownList>

                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel2" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:CheckBoxList ID="chlFormAPPROVAL_MAPPING" Label="对应模块" ColumnNumber="3" ColumnVertical="true" runat="server">
                                </f:CheckBoxList>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Toolbars>
                        <f:Toolbar ID="Toolbar1" Position="Bottom" ToolbarAlign="Right" runat="server">
                            <Items>
                                <f:Button ID="btnSave"
                                    Icon="SystemSave" runat="server" Text="保存" ValidateForms="SimpleForm1" OnClick="btnSave_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                </f:SimpleForm>
            </Items>
        </f:Window>


        <f:Window ID="Window2" Title="编辑审批流程" Hidden="true" EnableIFrame="false" AutoScroll="true"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="950px">
            <Items>
                <f:SimpleForm ID="SimpleForm2" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:Panel ID="Panel3" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                               <f:HiddenField ID="hfFormProcessID" runat="server"></f:HiddenField>
                                <f:DropDownList ID="ddlFormPROCESS_DEPT" Width="310px" Label="审批部门" EnableEdit="true" runat="server" AutoPostBack="true" 
                                    OnSelectedIndexChanged="ddlFormPROCESS_DEPT_SelectedIndexChanged">
                                </f:DropDownList>
                                  <f:DropDownList ID="ddlFormPROCESS_TYPE" Width="310px" MarginLeft="20px" Label="审批类别" AutoSelectFirstItem="true" runat="server">
                                </f:DropDownList>
                                <f:NumberBox  ID="tbxFormPROCESS_SEQ" Width="310px" MarginLeft="20px" NoDecimal="true" ShowTrigger="false" ShowRedStar="true" Label="顺序" 
                                    Required="true" runat="server"></f:NumberBox>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel4" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:CheckBoxList ID="chlFormPROCESS_USER" Label="审批人员" ColumnNumber="3" ColumnVertical="true" runat="server">
                               </f:CheckBoxList>
                            </Items>
                        </f:Panel>
                    </Items>
                     <Items>
                        <f:Panel ID="Panel5" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:TextArea runat="server" Label="备注" ID="tbxFormPROCESS_REMARK" />
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel6" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:Button ID="btnSaveProcess"
                                    Icon="SystemSave" runat="server" Text="保存"  OnClick="btnSaveProcess_Click">
                                </f:Button>
                            </Items>
                        </f:Panel>
                    </Items>
                </f:SimpleForm>
                <f:GroupPanel runat="server" ID="Panel_ApprovalInfo" Title="流程信息" Layout="Fit" BoxFlex="1" MinHeight="120">
                    <Items>
                        <f:Grid ID="GridProcess" runat="server" ShowBorder="true" ShowHeader="false" OnRowCommand="GridProcess_RowCommand"
                            DataKeyNames="REC_ID" EnableColumnLines="true" EnableRowLines="true"  EnableRowDoubleClickEvent="true" OnRowDoubleClick="GridProcess_RowClick">
                            <Columns>
                                <f:BoundField runat="server" ID="PROCESS_SEQ" ColumnID="PROCESS_SEQ" DataField="PROCESS_SEQ" HeaderText="顺序" HeaderTextAlign="Center" TextAlign="Center" Width="100px" />
                                <f:BoundField runat="server" ID="PROCESS_DEPT_NAME" ColumnID="PROCESS_DEPT_NAME" DataField="PROCESS_DEPT_NAME" HeaderText="审批部门" HeaderTextAlign="Center" TextAlign="Center" Width="120px" />
                                <f:BoundField runat="server" ID="PROCESS_TYPE_NAME" ColumnID="PROCESS_TYPE_NAME" DataField="PROCESS_TYPE_NAME" HeaderText="审批类别" HeaderTextAlign="Center" TextAlign="Center" Width="100px" />
                                <f:BoundField runat="server" ID="PROCESS_USER_NAME" ColumnID="PROCESS_USER_NAME" DataField="PROCESS_USER_NAME" HeaderText="审批人员" HeaderTextAlign="Center" TextAlign="Center" Width="150px" />
                                <f:BoundField runat="server" ID="PROCESS_REMARK" ColumnID="PROCESS_REMARK" DataField="PROCESS_REMARK" HeaderText="备注" HeaderTextAlign="Center" TextAlign="Center" Width="150" />
                                <f:BoundField runat="server" ID="PROCESS_DEPT" ColumnID="PROCESS_DEPT" DataField="PROCESS_DEPT" Hidden="true"/>
                                <f:BoundField runat="server" ID="PROCESS_TYPE" ColumnID="PROCESS_TYPE" DataField="PROCESS_TYPE" Hidden="true"/>
                                <f:BoundField runat="server" ID="PROCESS_USER" ColumnID="PROCESS_USER" DataField="PROCESS_USER" Hidden="true"/>
                                <f:LinkButtonField Width="50px" ConfirmText="删除选中行？" ConfirmTarget="Top"
                            CommandName="Delete" Icon="Delete" />
                            </Columns>
                        </f:Grid>
                    </Items>
                </f:GroupPanel>
            </Items>
        </f:Window>
        <br />
        <br />
        <br />
    </form>
    <script src="../res/js/ApprovalButton.js"></script>
    <script>
        var windowClientID = '<%= Window1.ClientID %>';
        var gridClientID = '<%= Grid1.ClientID %>';
        var btnSaveClientID = '<%= btnSave.ClientID %>';
        var formClientID = '<%= SimpleForm1.ClientID %>';
        var hfFormIDClientID = '<%= hfFormID.ClientID %>';
        var tbxFormAPPROVAL_NAMEClientID = '<%= tbxFormAPPROVAL_NAME.ClientID %>';
        var tbxFormAPPROVAL_REMARKClientID = '<%= tbxFormAPPROVAL_REMARK.ClientID %>';
        var ddlFormAPPROVAL_STATUSClientID = '<%= ddlFormAPPROVAL_STATUS.ClientID %>';
        var chlFormAPPROVAL_MAPPINGClientID = '<%= chlFormAPPROVAL_MAPPING.ClientID %>';


        function onNewButtonClick(event) {
            // 重置表单字段
            F(formClientID).reset();
            F(hfFormIDClientID).setValue(null);
            // 弹出窗体
            F(windowClientID).show();
            F(windowClientID).setTitle('新增数据');
        }
        function onEditButtonClick(event) {
            showEditWindow();
        }
        function showEditWindow(rowId) {
            var grid = F(gridClientID);

            // 如果传入参数为空，则获取当前选中行
            if (!rowId) {
                var selectedRowIds = grid.getSelectedRows();
                if (!selectedRowIds.length) {
                    F.alert('请至少选择一项！');
                    return;
                }

                rowId = selectedRowIds[0];
            }
            F(windowClientID).setTitle('编辑数据');
            // 当前行数据
            var rowValue = grid.getRowValue(rowId);
            // 使用当前行数据填充表单字段
            F(hfFormIDClientID).setValue(rowId);
            F(tbxFormAPPROVAL_NAMEClientID).setValue(rowValue['APPROVAL_NAME']);
            F(tbxFormAPPROVAL_REMARKClientID).setValue(rowValue['APPROVAL_REMARK']);
            F(ddlFormAPPROVAL_STATUSClientID).setValue(rowValue['APPROVAL_STATUS']);
            var mappingValue = rowValue['APPROVAL_MAPPING'].split(',');
            F(chlFormAPPROVAL_MAPPINGClientID).setValue(mappingValue);
           
            // 弹出新增窗体
            F(windowClientID).show();
        }
    </script>
</body>
</html>

